<template>
	<view id="page-line-list">
		<uni-list>
			<uni-list-item 
			:title="item.lineName" 
			:show-extra-icon="true" 
			iconType="ali"
			:extra-icon="{color: '#4cd964',size: '22',type: 'e630'}"
			 v-for="(item,index) in lineList" 
			 :key="index" 
			 @click="show(item)">
			</uni-list-item>
		</uni-list>
		<uni-popup :show="popup" type="middle" mode="fixed" msg="接口能力有限,找不到你所需的线路" @hidePopup="hidePopup"></uni-popup>
	</view>
</template>

<script>
	import uniList from '@/components/uni-list/uni-list.vue'
	import uniListItem from '@/components/uni-list-item/uni-list-item.vue'
	import uniPopup from "@/components/uni-popup/uni-popup.vue"
	import {
		api_getLineList1,
		api_getLineList2
	} from '../../api/api.transit.js'
	import {
		createNamespacedHelpers
	} from 'vuex'
	const {
		mapState,
		mapActions,
		mapMutations
	} = createNamespacedHelpers('lineList')
	export default {
		components:{uniList,uniListItem,uniPopup},
		data() {
			return {
				popup:false
			};
		},
		computed:{
			...mapState(['lineList'])
		},
		methods:{
			...mapMutations(['SET_LINE_NAME']),
			...mapActions(['GET_LINE_LIST','GET_LINE_ID','PASS_LINE']),
			hidePopup(){
				this.popup=false
			},
			show(item){
				this.SET_LINE_NAME(item.lineName)
				this.GET_LINE_ID()
					.then((res) => {
						console.log(res)
						this.PASS_LINE(res)
						uni.navigateTo({
							url: '../../pages/line-details/line-details'
						});
					})
					.catch(() => {
						this.popup=true
					})
			}
		},
		onLoad() {
			//获取（站点）线路列表
			this.GET_LINE_LIST()
				.then((res)=>{

				})
				.catch(() => {
					console.log('出错')
				})	
		}
	}
</script>

<style lang="scss">
#page-line-list{
	width: 100%;
	min-height: 100%;
	padding: 20upx 0;
}
</style>
